package demo1;

/**
 * Created with IntelliJ IDEA.
 * Description:日期类
 * User: 何华树
 * Date: 2024-07-12
 * Time: 16:43
 */
public class Date {
    public int year;
    public int month;
    public int day;
//    public void SetDay(int year,int month,int day) {
//        year = year;
//        month = month;
//        day = day;
//局部变量优先使用，这样的代码，不会给 Date类 里面的成员变量赋值
//成员变量：year month day 的值都是默认值 0
//    }
    public Date() {
//        this.year = 1990;
        System.out.println("不带参数的构造方法");
    }
    public Date(int year,int month,int day) {
        this.year = year;
        this.month = month;
        this.day = day;
        System.out.println("调用带有三个参数的构造方法");
    }    //构造方法可以发生重载

    public void SetDay(int year,int month,int day) {
        this.year = year;
        this.month = month;
        this.day = day;
    }
    public void PrintDay() {
        System.out.println(this.year+"年 "+this.month+"月 "+this.day+"日 ");
        //this.test();//this 可以访问当前对象的非静态成员方法。
    }
    public void test() {
        System.out.println("简单测试一下");
    }

    public static void main(String[] args) {
//        Date date = new Date();
//        date.SetDay(2008,8,8);
//        date.PrintDay();
//
//        Date date2 = new Date();
//        date2.SetDay(2009,9,9);
//        date2.PrintDay();

        Date date3 = new Date(2022,12,12);
        date3.PrintDay();

    }
}
